const baseConfig = require('./webpack.base.config.js')
const merge = require('webpack-merge')
const isDev = process.env.NODE_ENV === 'development'
const CleanWebpackPlugin = require('clean-webpack-plugin')
let config
if (isDev) {
  config = merge(baseConfig, {
    devServer: {
      contentBase: '../dist',
      host: '127.0.0.1',
      port: '8080',
      hot: true,
      overlay: {// 显示webpack的错误
        errors: true
      },
      historyApiFallback: {
        // index: '/public/index.html'
        index: '/index.html'
      }
    }
  })
} else {
  config = merge(baseConfig, {
    plugins: [new CleanWebpackPlugin()]
  })
}

module.exports = config
